#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
int a[maxn];
int n;
void solve(){
    cin>>n;
    for(int i = 1;i<=n;i++)cin>>a[i];
    int ans = 0;
    for(int zt = 0;zt<=(1<<n)-1;zt++){
        int sum = 0;
        for(int i = n;i>=1;i--){
            for(int k = i-1;k>=1;k--){
                if((zt>>i) == (zt>>k)&&a[i] == a[k]){
                    sum+=a[i];
                    break;
                }
            }
        }
        ans = max(ans,sum);
    }
    cout<<ans<<'\n';
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}
